package utils;
import java.util.*;
public class UserForTest {
	public int id;
	public List<UserRecCount> allUserB;
	public List<UserRecCount> allUserBSort;
	int[] ranks;
	public UserForTest(String id){
		this.id = new Integer(id);
		allUserB = new ArrayList<UserRecCount>();
	}
	public void addUser(String id, String recCount){
		allUserB.add(new UserRecCount(id,recCount));
	}
	public void rankUserB(){
		allUserBSort =  new ArrayList<UserRecCount>(allUserB);
		Collections.sort(allUserB,new UserBComparator());
		ranks = new int[allUserB.size()];
		for(int i = 0; i < ranks.length; i++){
			int index = 0;
			for(int j = 0 ; j < allUserBSort.size();j++)
				if(allUserBSort.get(j).id == allUserB.get(i).id)	{
					index = j;
					break;
				}
					
			ranks[i] = index+1;
		}
	}
	public String toString()	{
		StringBuffer sb = new StringBuffer();
		for(int id : ranks){
			sb.append(id + " ");
		}
		return sb.toString().trim();
	}
	

}
class UserBComparator implements Comparator<UserRecCount>	{

	@Override
	public int compare(UserRecCount u1, UserRecCount u2) {
		if(u1.score > u2.score)
			return -1;
		if(u1.score < u2.score)
			return 1;
		// TODO Auto-generated method stub
		return 0;
	}
	
}

